< previous page page_149 next page >

Page 149
Solution 1
Where, Oh, Where Is That API Call?
The declaration may have looked reasonable, but it actually had two errors. Though the function may be called GetUserDefaultLCID, locales relate to the operating system and thus are part of the kernel32 DLL, not the User32 DLL shown in the original declaration.
Next, Win32 function names are case-sensitive (unlike those in 16-bit Windows). Most API function names that contain multiple words have the first letter of each word capitalized, as you have within the function GetWindowText function. But an LCID is an acronym (for LoCale IDentifier) and thus is capitalized.
It's very easy to overlook these errors. The good news is that this error is one that Visual Basic not only detects, but also clearly identifies. If you get runtime error 453 (Can't find DLL entry point), the problem is almost certainly in the declarationspecifically, an error in the function name or the library name.
The corrected code below not only fixes the problem, but also shows you how to use the locale identifier to obtain the English name of the language in use at that locale.
' Where, oh, Where Is that API Call?
' Copyright © 1998 by Desaware Inc. All Rights Reserved

Option Explicit

Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long

Private Const LOCALE_SENGLANGUAGE = &H1001&
' English name of language
Private Declare Function GetLocaleInfo Lib "kernel32" Alias _
"GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, _
ByVal lpLCData As String, ByVal cchData As Long) As Long

Private Sub Command1_Click()
   Dim lcid&
   Dim info$

 
< previous page page_149 next page >